<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>参数设置</title>
<link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css"></link>
<link rel="stylesheet" type="text/css" href="../ext/resources/css/xtheme-slate.css"></link>
<script src="../ext/adapter/ext/ext-base.js"></script>
<script src="../ext/ext-all.js"></script>
<script src="../ext/src/locale/ext-lang-zh_CN.js"></script>	
<script src="../ext/base/PagingMemoryProxy.js"></script>	
<script type="text/javascript">
Ext.onReady(function(){
	Ext.Ajax.on('requestcomplete',checkUserSessionStatus, this);      
	function checkUserSessionStatus(conn,response,options){      
	    if(response.getResponseHeader('sessionstatus')){      
	    	parent.location.href='/xdj/index.jsp';   
	    }      
	}  
	Ext.BLANK_IMAGE_URL='ext/resources/images/default/s.gif';
	//TabPanel 开始 就是每个选项框附在框架右边的
	
	/*******************************巡检方法**********************************************/
	var form1 = new Ext.form.FormPanel({});

	var store=new Ext.data.JsonStore({
	 	url: 'chkmeans_load',
	 	autoLoad : true,
	 	// root: 'result',
	 	// idProperty:'id',
		//totalProperty:'result',
	    fields: ["chkMeansID", "chkMeansName"]
	});//存储前两项的定义的东西，将其连接起来
	
	var cm=new Ext.grid.ColumnModel([
		new Ext.grid.RowNumberer(),  //自动增加序列号
		{header:'巡检方法',dataIndex:'chkMeansName',sortable:true},
	    {header:'chkMeansID',dataIndex:"chkMeansID",hidden:true}
	]);//定义相应的列模型
	
	var panel = new Ext.grid.GridPanel({
		cm:cm,
		//sm:sm,
		store:store,
		border:false,
		autoHeight:true,  //设置表格的高度 true为自动获取表格的大小
		renderTo:'grid' , //渲染容器
		enableColumnMove:false,//不可以使表格列移动
		enableColumnResize:false, //不可以改变列的宽度
		stripeRows:false, //True表示为显示行的分隔符
		loadMask:true,  //会有一个Ext.LoadMask的遮罩效果
		trackMouseOver : true,  //True表示为鼠标移动时高亮显示（默认为true）。
		enableDragDrop : true,
		viewConfig:{
			forceFit:true //让没列自动填满表格，根据你设置的宽度按比例分配
		},
		tbar:[{
	    	text: "删除",disabled:true,id:'cPageCHKMeanscDeleteBox',
	    	icon:'../image/public/user_delete.png',
	    	handler:function() {
	    		Ext.MessageBox.confirm("提示","您确定要删除这些信息吗?", function(button,text){   
					if(button=='yes'){
						var record=panel.getSelectionModel().getSelected();
						if(record==null){
							alert("请选择要删除的信息");
						}else{
							Ext.Ajax.request({
								url:'chkmeans_delete',
								success:function(response){
									var result = Ext.util.JSON.decode(response.responseText);
									if(result.success==true){
										store.load({});
									}else{
										Ext.Msg.alert("提示","操作失败，请重试。") ;
									}
								},
								params:{chkMeansID:record.get("chkMeansID")}
							});	
						}
						
					}
	    		});
	    	}
		},{
			text: "修改",disabled:true,id:'cPageCHKMeanscModifyBox',
			icon:'../image/public/user_edit.png',
			handler:function() {
				Ext.MessageBox.confirm("提示","您确定要修改这些信息吗?", function(button,text){   
					if(button=='yes'){
						var record=panel.getSelectionModel().getSelected();
						if(record==null){
							alert("请选择要修改的信息");
						}else{
							Ext.getBody().mask();
							showWindown("chkmeans_update");
			        		form1.getForm().setValues({
			        			"chkmeans.chkMeans" : record.get("chkMeansName"),
			        			"chkmeans.chkMeansID": record.get("chkMeansID")
			        		});
						}
						
		        		
					}
				});
				
			}
			
		},{
	    	text: '增加',disabled:true,id:'cPageCHKMeanscAddBox',
	    	icon:'../image/public/user_add.gif',
	        handler:function(){
	        	Ext.getBody().mask();
	        	showWindown("chkmeans_save");
	        }
		}],
	    bbar:new Ext.PagingToolbar({
	    pageSize:3,  //每页显示几条
	    store:store,
	    displayInfo:true,
	    displayMsg:'显示{0}，到{1}条，一共{2}',  //固定写法
	    emptyMsg:'无此记录'
	  })
	 });
	
	function showWindown(urlString) {
		form1=new Ext.form.FormPanel({
		frame:true,
		height:250,
		buttonAlign:'top',
		layout:'form',
		items:[{
			fieldLabel:'巡检方法',
			xtype:'textfield',
			allowBlank:false,
			blankText:'不能为空',
			name:'chkmeans.chkMeans'
		},{
			xtype:'hidden',
			name:'chkmeans.chkMeansID'
		}
		],
		buttons:[{
			text: "确认",
		       handler:function(){ 
		    	   if ( form1.getForm().isValid() ){
		    	    form1.form.submit({
		        	waitMsg : '正在提交数据....',   
		            url:urlString,   
		            method:'post', 
			            success:function(form1,action){  
			            	var result = Ext.util.JSON.decode(action.response.responseText);
			            	if(result.success==true) {
			            		if(urlString=="chkmeans_save"){
			            			win.close();
			            			store.load({});
			            			Ext.getBody().unmask();
			            		}else if(urlString=="chkmeans_update"){
			            			win.close() ;
			            			store.load({});
			            			Ext.getBody().unmask();
			            		}
			            		Ext.getBody().unmask();
			            	}else{
			            		Ext.Msg.alert("提示","操作失败，请重试。") ;
			            	}
			            }
			          }); 
			       }
			       }
	     },{
	        text: "取消",
	        handler:function(){ 
	           	win.close() ;
	           	Ext.getBody().unmask();
	        }
	     }]
		});

		var win=new Ext.Window({
			//title:'添加路线',
			 width:400,
			 height:300,
			 items:[form1],
			 xtype:'form',
			 listeners:{"beforedestroy":function(obj)
                 { 
				 Ext.getBody().unmask();  
                    // obj.show(); return false; 
                  }
			}  
		});
		win.show();
	}

	/*******************************巡检项目类型**********************************************/
	var form2 = new Ext.form.FormPanel({});

	var store2=new Ext.data.JsonStore({
	 	url: 'chktype_load',
	 	autoLoad : true,
	 	// root: 'result',
	 	// idProperty:'id',
		//totalProperty:'result',
	    fields: ["chkTypeCode", "chkTypeName"]
	});//存储前两项的定义的东西，将其连接起来
	
	var cm2=new Ext.grid.ColumnModel([
		new Ext.grid.RowNumberer(),  //自动增加序列号
		{header:'巡检项目类型编号',dataIndex:'chkTypeCode',sortable:true},
	    {header:'巡检项目类型名称',dataIndex:"chkTypeName"}
	]);//定义相应的列模型
	
	var panel2 = new Ext.grid.GridPanel({
		cm:cm2,
		//sm:sm,
		store:store2,
		border:false,
		autoHeight:true,  //设置表格的高度 true为自动获取表格的大小
		//renderTo:'grid2' , //渲染容器
		enableColumnMove:false,//不可以使表格列移动
		enableColumnResize:false, //不可以改变列的宽度
		stripeRows:false, //True表示为显示行的分隔符
		loadMask:true,  //会有一个Ext.LoadMask的遮罩效果
		trackMouseOver : true,  //True表示为鼠标移动时高亮显示（默认为true）。
		enableDragDrop : true,
		viewConfig:{
			forceFit:true //让没列自动填满表格，根据你设置的宽度按比例分配
		},
		tbar:[{
	    	text: "删除",disabled:true,id:'cPageCHKTypecDeleteBox',
	    	icon:'../image/public/user_delete.png',
	    	handler:function() {
	    		var record=panel2.getSelectionModel().getSelected();
	    		if(record==null){
					alert("请选择要删除的信息");
				}else{
					Ext.Ajax.request({
						url:'chktype_delete',
						success:function(response){
							var result = Ext.util.JSON.decode(response.responseText);
							if(result.success==true){
								store2.load({});
							}else{
								Ext.Msg.alert("提示","操作失败，请重试。") ;
							}
						},
						params:{chkTypeCode:record.get("chkTypeCode")}
					});
				}
				
	    	}
		},{
			text: "修改",disabled:true,id:'cPageCHKTypecModifyBox',
			icon:'../image/public/user_edit.png',
			handler:function() {
				var record=panel2.getSelectionModel().getSelected();
				if(record==null){
					alert("请选择要修改的信息");
				}else{
					Ext.getBody().mask();
					showWindown2("chktype_update");
	        		form2.getForm().setValues({
	        			"chkType.chkTypeCode" : record.get("chkTypeCode"),
	        			"chkType.chkTypeName": record.get("chkTypeName")
	        		});
	        		form2.getForm().findField("chkType.chkTypeCode").setReadOnly(true);
				}
        		
			}
			
		},{
	    	text: '增加',disabled:true,id:'cPageCHKTypecAddBox',
	    	icon:'../image/public/user_add.gif',
	        handler:function(){
	        	showWindown2("chktype_save");
	        }
		}],
	    bbar:new Ext.PagingToolbar({
	    pageSize:3,  //每页显示几条
	    store:store2,
	    displayInfo:true,
	    displayMsg:'显示{0}，到{1}条，一共{8}',  //固定写法
	    emptyMsg:'无此记录'
	  })
	 });
	
	function showWindown2(urlString) {
		form2=new Ext.form.FormPanel({
		frame:true,
		height:250,
		buttonAlign:'top',
		layout:'form',
		items:[{
			fieldLabel:'巡检项目类型编号',
			xtype:'textfield',
			allowBlank:false,
			blankText:'不能为空',
			name:'chkType.chkTypeCode'
		},{
			fieldLabel:'巡检项目类型名称',
			xtype:'textfield',
			allowBlank:false,
			blankText:'不能为空',
			name:'chkType.chkTypeName'
		}
		],
		buttons:[{
			text: "确认",
		       handler:function(){ 
		    	   if ( form2.getForm().isValid() ){
		    	    form2.form.submit({
		        	waitMsg : '正在提交数据....',   
		            url:urlString,   
		            method:'post', 
			            success:function(form2,action){  
			            	var result = Ext.util.JSON.decode(action.response.responseText);
			            	if(result.success==true) {
			            		if(urlString=="chktype_save"){
			            			win.close();
			            			store2.load({});
			            		}else if(urlString=="chktype_update"){
			            			win.close() ;
			            			store2.load({});
			            		}
			            		Ext.getBody().unmask();
			            	}else{
			            		Ext.Msg.alert("提示","操作失败，请重试。") ;
			            	}
			            }
			          }); 
			       }
			       }
	     },{
	        text: "取消",
	        handler:function(){ 
	           	win.close() ;
	        }
	     }]
		});

		var win=new Ext.Window({
			title:'添加路线',
			 width:400,
			 height:300,
			 items:[form2],
			 xtype:'form'
		});
		win.show();
	}
	
	/*******************************异常等级**********************************************/
	var form3 = new Ext.form.FormPanel({});

	var store3=new Ext.data.JsonStore({
	 	url: 'buglevel_load',
	 	autoLoad : true,
	 	// root: 'result',
	 	// idProperty:'id',
		//totalProperty:'result',
	    fields: ["bugLevelID", "bugLevelName"]
	});//存储前两项的定义的东西，将其连接起来
	
	var cm3=new Ext.grid.ColumnModel([
		new Ext.grid.RowNumberer(),  //自动增加序列号
		{header:'异常等级编号',dataIndex:'bugLevelID',sortable:true},
	    {header:'异常等级名称',dataIndex:"bugLevelName"}
	]);//定义相应的列模型
	
	var panel3 = new Ext.grid.GridPanel({
		cm:cm3,
		//sm:sm,
		store:store3,
		border:false,
		autoHeight:true,  //设置表格的高度 true为自动获取表格的大小
		//renderTo:'grid2' , //渲染容器
		enableColumnMove:false,//不可以使表格列移动
		enableColumnResize:false, //不可以改变列的宽度
		stripeRows:false, //True表示为显示行的分隔符
		loadMask:true,  //会有一个Ext.LoadMask的遮罩效果
		trackMouseOver : true,  //True表示为鼠标移动时高亮显示（默认为true）。
		enableDragDrop : true,
		viewConfig:{
			forceFit:true //让没列自动填满表格，根据你设置的宽度按比例分配
		},
		tbar:[{
	    	text: "删除",disabled:true,id:'cPageBugLevelcDeleteBox',
	    	icon:'../image/public/user_delete.png',
	    	handler:function() {
	    		var record=panel3.getSelectionModel().getSelected();
	    		if(record==null){
					alert("请选择要删除的信息");
				}else{
					Ext.Ajax.request({
						url:'buglevel_delete',
						success:function(response){
							var result = Ext.util.JSON.decode(response.responseText);
							if(result.success==true){
								store3.load({});
							}else{
								Ext.Msg.alert("提示","操作失败，请重试。") ;
							}
						},
						params:{bugLevelID:record.get("bugLevelID")}
					});
				}
				
	    	}
		},{
			text: "修改",disabled:true,id:'cPageBugLevelcModifyBox',
			icon:'../image/public/user_edit.png',
			handler:function() {
				var record=panel3.getSelectionModel().getSelected();
				if(record==null){
					alert("请选择要修改的信息");
				}else{
					Ext.getBody().mask();
					showWindown3("buglevel_update");
	        		form3.getForm().setValues({
	        			"bugLevel.bugLevel" : record.get("bugLevelID"),
	        			"bugLevel.bugLevelName": record.get("bugLevelName")
	        		});
	        		form3.getForm().findField("bugLevel.bugLevel").setReadOnly(true);//控件不置灰，但不可编辑传值到后台
				}
        		
			}
			
		},{
	    	text: '增加',disabled:true,id:'cPageBugLevelcAddBox',
	    	icon:'../image/public/user_add.gif',
	        handler:function(){
	        	showWindown3("buglevel_save");
	        }
		}],
	    bbar:new Ext.PagingToolbar({
	    pageSize:3,  //每页显示几条
	    store:store3,
	    displayInfo:true,
	    displayMsg:'显示{0}，到{1}条，一共{8}',  //固定写法
	    emptyMsg:'无此记录'
	  })
	 });
	
	function showWindown3(urlString) {
		form3=new Ext.form.FormPanel({
		frame:true,
		height:250,
		buttonAlign:'top',
		layout:'form',
		items:[{
			fieldLabel:'异常等级编号',
			xtype:'textfield',
			allowBlank:false,
			blankText:'不能为空',
			name:'bugLevel.bugLevel'
		},{
			fieldLabel:'异常等级名称',
			xtype:'textfield',
			allowBlank:false,
			blankText:'不能为空',
			name:'bugLevel.bugLevelName'
		}
		],
		buttons:[{
			text: "确认",
		       handler:function(){ 
		    	   if ( form3.getForm().isValid() ){
		    	    form3.form.submit({
		        	waitMsg : '正在提交数据....',   
		            url:urlString,   
		            method:'post', 
			            success:function(form3,action){  
			            	var result = Ext.util.JSON.decode(action.response.responseText);
			            	if(result.success==true) {
			            		if(urlString=="buglevel_save"){
			            			win.close();
			            			store3.load({});
			            		}else if(urlString=="buglevel_update"){
			            			win.close() ;
			            			store3.load({});
			            		}
			            		Ext.getBody().unmask();
			            	}else{
			            		Ext.Msg.alert("提示","操作失败，请重试。") ;
			            	}
			            }
			          }); 
			       }
			       }
	     },{
	        text: "取消",
	        handler:function(){ 
	           	win.close() ;
	        }
	     }]
		});

		var win=new Ext.Window({
			title:'添加路线',
			 width:400,
			 height:300,
			 items:[form3],
			 xtype:'form'
		});
		win.show();
	}
	
	/*******************************设备运行状态**********************************************/
	var form4 = new Ext.form.FormPanel({});

	var store4=new Ext.data.JsonStore({
	 	url: 'devicerunstate_load',
	 	autoLoad : true,
	 	// root: 'result',
	 	// idProperty:'id',
		//totalProperty:'result',
	    fields: ["deviceRunStateCode", "deviceRunStateName"]
	});//存储前两项的定义的东西，将其连接起来
	
	var cm4=new Ext.grid.ColumnModel([
		new Ext.grid.RowNumberer(),  //自动增加序列号
		{header:'设备运行状态编号',dataIndex:'deviceRunStateCode',sortable:true},
	    {header:'设备运行状态名称',dataIndex:"deviceRunStateName"}
	]);//定义相应的列模型
	
	var panel4 = new Ext.grid.GridPanel({
		cm:cm4,
		//sm:sm,
		store:store4,
		border:false,
		autoHeight:true,  //设置表格的高度 true为自动获取表格的大小
		//renderTo:'grid2' , //渲染容器
		enableColumnMove:false,//不可以使表格列移动
		enableColumnResize:false, //不可以改变列的宽度
		stripeRows:false, //True表示为显示行的分隔符
		loadMask:true,  //会有一个Ext.LoadMask的遮罩效果
		trackMouseOver : true,  //True表示为鼠标移动时高亮显示（默认为true）。
		enableDragDrop : true,
		viewConfig:{
			forceFit:true //让没列自动填满表格，根据你设置的宽度按比例分配
		},
		tbar:[{
	    	text: "删除",disabled:true,id:'cPageDeviceRunStatecDeleteBox',
	    	icon:'../image/public/user_delete.png',
	    	handler:function() {
	    		var record=panel4.getSelectionModel().getSelected();
	    		if(record==null){
					alert("请选择要删除的信息");
				}else{
					Ext.Ajax.request({
						url:'devicerunstate_delete',
						success:function(response){
							var result = Ext.util.JSON.decode(response.responseText);
							if(result.success==true){
								store4.load({});
							}else{
								Ext.Msg.alert("提示","操作失败，请重试。") ;
							}
						},
						params:{deviceRunStateCode:record.get("deviceRunStateCode")}
					});
				}
				
	    	}
		},{
			text: "修改",disabled:true,id:'cPageDeviceRunStatecModifyBox',
			icon:'../image/public/user_edit.png',
			handler:function() {
				var record=panel4.getSelectionModel().getSelected();
				if(record==null){
					alert("请选择要修改的信息");
				}else{
					Ext.getBody().mask();
					showWindown4("devicerunstate_update");
	        		form4.getForm().setValues({
	        			"deviceRunState.deviceRunStateCode" : record.get("deviceRunStateCode"),
	        			"deviceRunState.deviceRunStateName": record.get("deviceRunStateName")
	        		});
	        		form4.getForm().findField("deviceRunState.deviceRunStateCode").setReadOnly(true);
				}
        		
			}
			
		},{
	    	text: '增加',disabled:true,id:'cPageDeviceRunStatecAddBox',
	    	icon:'../image/public/user_add.gif',
	        handler:function(){
	        	showWindown4("devicerunstate_save");
	        }
		}],
	    bbar:new Ext.PagingToolbar({
	    pageSize:3,  //每页显示几条
	    store:store4,
	    displayInfo:true,
	    displayMsg:'显示{0}，到{1}条，一共{8}',  //固定写法
	    emptyMsg:'无此记录'
	  })
	 });
	
	function showWindown4(urlString) {
		form4=new Ext.form.FormPanel({
		frame:true,
		height:250,
		buttonAlign:'top',
		layout:'form',
		items:[{
			fieldLabel:'设备运行状态编号',
			xtype:'textfield',
			allowBlank:false,
			blankText:'不能为空',
			name:'deviceRunState.deviceRunStateCode'
		},{
			fieldLabel:'设备运行状态名称',
			xtype:'textfield',
			allowBlank:false,
			blankText:'不能为空',
			name:'deviceRunState.deviceRunStateName'
		}
		],
		buttons:[{
			text: "确认",
		       handler:function(){ 
		    	   if ( form4.getForm().isValid() ){
		    	    form4.form.submit({
		        	waitMsg : '正在提交数据....',   
		            url:urlString,   
		            method:'post', 
			            success:function(form4,action){  
			            	var result = Ext.util.JSON.decode(action.response.responseText);
			            	if(result.success==true) {
			            		if(urlString=="devicerunstate_save"){
			            			win.close();
			            			store4.load({});
			            		}else if(urlString=="devicerunstate_update"){
			            			win.close() ;
			            			store4.load({});
			            		}
			            		Ext.getBody().unmask();
			            	}else{
			            		Ext.Msg.alert("提示","操作失败，请重试。") ;
			            	}
			            }
			          }); 
			       }
			       }
	     },{
	        text: "取消",
	        handler:function(){ 
	           	win.close() ;
	        }
	     }]
		});

		var win=new Ext.Window({
			title:'添加路线',
			 width:400,
			 height:300,
			 items:[form4],
			 xtype:'form'
		});
		win.show();
	}
	////////////////////////////////////

	var tabPanel = new Ext.TabPanel({  
		activeTab: 0,
		anchor:'100% 100%',
		height:300,
		defaults:{autoScroll:true},
		items:[{
			title:'巡检方法',
			items:[panel]
		},{
			title:'巡检项目类型',
			//autoLoad:{url:'userRole.jsp',scripts:true},
			items:[panel2]
		},{
			title:'异常等级',
			items:[panel3]
		},{
			title:'设备运行状态',
			items:[panel4]
		}]
	});
	
	 new Ext.Viewport({  
			layout : 'border', // 使用border布局  
			border:false,
			items:[{
				region:'center',
				border:false,
				items:[tabPanel]
			}],
			listeners:{
				'beforerender' : function(cmp) {
					var store=new Ext.data.JsonStore({
						url: '../system/role_loadFunc?funcCode=cPageCHKMeans',
						autoLoad : true,
						fields: ["functioncode"]
					});
					store.load({
					    callback: function(records, options, success){
					    	var i=0;
					    	for(; i<records.length; i++) {
					    		var id = 'cPageCHKMeans'+records[i].get("functioncode");
					    		//alert('d'+Ext.getCmp('56').text);
					    		if(Ext.getCmp(id)!=null) {
					    			Ext.getCmp(id).setDisabled(false);
					    		}
					        }
					    },
					    scope: store
					});
					var store2=new Ext.data.JsonStore({
						url: '../system/role_loadFunc?funcCode=cPageCHKType',
						autoLoad : true,
						fields: ["functioncode"]
					});
					store2.load({
					    callback: function(records, options, success){
					    	var i=0;
					    	for(; i<records.length; i++) {
					    		var id = 'cPageCHKType'+records[i].get("functioncode");
					    		//alert('d'+Ext.getCmp('56').text);
					    		if(Ext.getCmp(id)!=null) {
					    			Ext.getCmp(id).setDisabled(false);
					    		}
					        }
					    },
					    scope: store
					});
					var store3=new Ext.data.JsonStore({
						url: '../system/role_loadFunc?funcCode=cPageBugLevel',
						autoLoad : true,
						fields: ["functioncode"]
					});
					store3.load({
					    callback: function(records, options, success){
					    	var i=0;
					    	for(; i<records.length; i++) {
					    		var id = 'cPageBugLevel'+records[i].get("functioncode");
					    		//alert('d'+Ext.getCmp('56').text);
					    		if(Ext.getCmp(id)!=null) {
					    			Ext.getCmp(id).setDisabled(false);
					    		}
					        }
					    },
					    scope: store
					});
					var store4=new Ext.data.JsonStore({
						url: '../system/role_loadFunc?funcCode=cPageDeviceRunState',
						autoLoad : true,
						fields: ["functioncode"]
					});
					store4.load({
					    callback: function(records, options, success){
					    	var i=0;
					    	for(; i<records.length; i++) {
					    		var id = 'cPageDeviceRunState'+records[i].get("functioncode");
					    		//alert('d'+Ext.getCmp('56').text);
					    		if(Ext.getCmp(id)!=null) {
					    			Ext.getCmp(id).setDisabled(false);
					    		}
					        }
					    },
					    scope: store
					});
				}
			}
		 }); 
});
</script> 	
</head>
<body>
<div id="grid"></div>
</body>
</html>